package com.yzq.controller;

import com.yzq.common.Result;
import com.yzq.model.dto.likes.LikesRequest;
import com.yzq.service.LikesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(tags = "点赞管理")
@RequestMapping("/like")
@RestController
public class LikesController {

    @Resource
    private LikesService likesService;

    /**
     * 点赞图片
     * @param likesRequest 点赞请求
     * @param request 请求
     * @return 点赞结果
     */
    @ApiOperation("点赞图片")
    @PostMapping("/add")
    public Result<Boolean> likePicture(@RequestBody LikesRequest likesRequest, HttpServletRequest  request) {
        return Result.success(likesService.likePicture(likesRequest,  request));
    }

    /**
     * 取消点赞图片
     * @param likesRequest 点赞请求
     * @param request 请求
     * @return 取消点赞结果
     */
    @ApiOperation("取消点赞图片")
    @PostMapping("/cancel")
    public Result<Boolean> cancelLikePicture(@RequestBody LikesRequest likesRequest, HttpServletRequest  request) {
        return Result.success(likesService.cancelLikePicture(likesRequest, request));
    }
}
